import Vue from 'vue';
import {Notify} from 'quasar';

const BigFun = {
  getCharacterList: async () => {
    let list = [];
    /*
    try {
      let data_a = (await Vue.prototype.$axios.get('/bigfun/api/client/web', {
        params: {
          method: 'getGzljRoleList',
          is_online: 1,
          type: 2
        }
      })).data;
      let data_b = (await Vue.prototype.$axios.get('/bigfun/api/client/web', {
        params: {
          method: 'getGzljRoleList',
          is_online: 2,
          type: 2
        }
      })).data;
      list.concat(data_a.data);
      list.concat(data_b.data);
    } catch {
    }

     */
    try {
      let data = (await Vue.prototype.$axios.get('/characters.json')).data;
      list.concat(data.data);
    } catch {
    }
    // console.log(JSON.stringify(list));
    return list;
  },
  getCharacterInfo: async (id) => {
    /*
    // /static/api/1602215625642/client/web
    try {
      let ts = (await Vue.prototype.$axios.get('timestamp.json')).data.timestamp;
      let {data} = await Vue.prototype.$axios.get(`/bigfun/static/api/${ts}/client/web`, {
        params: {
          method: 'getGzljRoleDetail',
          role_id: id
        }
      })
      return data.data;
    } catch (e) {
      Notify.create({
        message: '错误',
        caption: 'API地址可能已变更，加载失败。',
        icon: 'clear'
      })
      throw e;
    }
     */
    // nmd毕方死活不更新数据 老子自己更行吧
    try {
      let {data} = await Vue.prototype.$axios.get(`data/characters/${id}.json`)
      return data.data;
    } catch (e) {
      Notify.create({
        message: '错误',
        caption: '获取角色详情失败。',
        icon: 'clear'
      })
      throw e;
    }
  }
}

export default BigFun;
